const superagent = require('superagent');

interface DataObj {};

function Http(method: String, url: String, data: DataObj) {
    return new Promise((resolve, reject) => {
        console.log(url);
        console.log(data);
        superagent(method, url)
			.query(method === 'GET' ? data : {})
			.send(data)
			.set('Content-Type', 'application/x-www-form-urlencoded')
			.end(function (err: any, response: any) {
				if (err) {
					reject(err)
				}
				resolve(response)
			})
    })
}

module.exports = Http;
